Skip to content

Fix/micro patches #811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 30, 2025
Merged

Fix/micro patches #811

merged 5 commits into from
Jun 30, 2025

Conversation

crazywhalecc
Copy link
Owner

@crazywhalecc crazywhalecc commented Jun 28, 2025

What does this PR do?

Fix #803 .

This PR will put micro patches after init souces and reuse patchFile function to automatically skip the patched patches.

Checklist before merging

If your PR involves the changes mentioned below and completed the action, please tick the corresponding option.
If a modification is not involved, please skip it directly.

  • If you modified *.php or *.json, run them locally to ensure your changes are valid:
    • PHP_CS_FIXER_IGNORE_ENV=1 composer cs-fix
    • composer analyse
    • composer test
    • bin/spc dev:sort-config
  • If it's an extension or dependency update, please ensure the following:
    • Add your test combination to src/globals/test-extensions.php.
    • If adding new or fixing bugs, add commit message containing extension test or test extensions to trigger full test suite.

Copilot

This comment was marked as outdated.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@crazywhalecc
Copy link
Owner Author

Seems it broke windows builds. I'll figure it out tomorrow.

@crazywhalecc
Copy link
Owner Author

Seems it has no patch file checking before applying patches. The directory separator caused the patch does not exist and failed to patch, but no exception.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors how micro patches are applied by centralizing patch logic into the existing patchFile method and updating default patch lists in configuration.

  • Removed legacy FileSystem::addSourceExtractHook('micro', …) and simplified patchMicro signature.
  • Switched manual file concatenation in patchMicro to reuse patchFile.
  • Updated BuilderBase to invoke patchMicro after source extraction and trimmed SPC_MICRO_PATCHES defaults in env.ini.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/SPC/store/SourcePatcher.php Simplified patchMicro, enhanced patchFile to handle absolute paths
src/SPC/builder/BuilderBase.php Added invocation of SourcePatcher::patchMicro() after ext extraction
config/env.ini Reduced default SPC_MICRO_PATCHES entries for Win32 and macOS contexts
Comments suppressed due to low confidence (3)

src/SPC/store/SourcePatcher.php:107

  • Update the docblock above patchMicro to reflect its new signature (removing $name and $target, and documenting the $items parameter correctly).
    public static function patchMicro(?array $items = null): bool

src/SPC/store/SourcePatcher.php:176

  • Inconsistent handling of missing patch files: sometimes returns false and later throws an exception. Consider standardizing on one approach for missing patches.
            return false;

src/SPC/store/SourcePatcher.php:107

  • [nitpick] The parameter name $items is ambiguous; consider renaming it to something more descriptive like $patches to clarify its purpose.
    public static function patchMicro(?array $items = null): bool

} else {
$patch_file = $patch_name;
}
if (!file_exists($patch_file)) {
Copy link
Preview

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The initial file_exists($patch_file) check makes the subsequent file_exists($patch_str) check redundant; consider removing one or consolidating the logic.

Copilot uses AI. Check for mistakes.

if (\Phar::running() !== '') {
file_put_contents(SOURCE_PATH . '/' . $patch_name, file_get_contents($patch_file));
$patch_str = str_replace('/', DIRECTORY_SEPARATOR, SOURCE_PATH . '/' . $patch_name);
if (str_starts_with($patch_str, 'phar://')) {
Copy link
Preview

Copilot AI Jun 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking str_starts_with($patch_str, 'phar://') may never detect the PHAR context correctly since $patch_str is a filesystem path. Consider using \Phar::running() to detect runtime in a PHAR archive as before.

Suggested change
if (str_starts_with($patch_str, 'phar://')) {
if (\Phar::running() !== '') {

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@henderkes henderkes merged commit 840e09a into main Jun 30, 2025
9 checks passed
@henderkes henderkes deleted the fix/micro-patches branch June 30, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract bug: re-extract micro will apply micro-patch multiple times to php-src
2 participants